/**
 * Baijiahulian.com Inc. Copyright (c) 2014-2017 All Rights Reserved.
 */
package com.baijia.web.aegis;

import com.baijia.aegis.exception.TooFrequentInvokeException;
import com.baijia.aegis.policy.Policy;
import com.baijia.web.dto.response.MobileResponse;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * @title SendPasscodeAttackPolicy
 * @desc 对passport攻击行为的封禁策略
 * @author macrohuang
 * @date Jan 10, 2017
 * @version version
 */
@Component("sendPasscodePolicy")
@Slf4j
public class SendPasscodeAttackPolicy implements Policy {

    /*
     * (non-Javadoc)
     * 
     * @see com.baijia.aegis.policy.Policy#getResult(java.lang.Object[], java.lang.Object[])
     */
    @Override
    public Object getResult(Object[] exceedKeys, Object...params) throws TooFrequentInvokeException {
        MobileResponse<String> response = new MobileResponse<>();
        response.fail().msg("获取短信验证码过于频繁！");
        log.debug("Blocked! {}, params {}", response, ToStringBuilder.reflectionToString(params));
        return response;
    }
}
